package com.example.websockettest.webSocket.回收站;

import com.baidu.aip.speech.AipSpeech;
import org.json.JSONObject;

import java.util.Base64;

public class ASRClient {
    private AipSpeech client;

    public ASRClient(String appID, String apiKey, String secretKey) {
        client = new AipSpeech(appID, apiKey, secretKey);
    }

    public String recognize(String audioData, int len) {
        byte[] audioBytes = Base64.getDecoder().decode(audioData);
        JSONObject res = client.asr(audioBytes, "pcm", 16000, null);
        return res.toString();
    }
    public String recognize(byte[] audioBytes) {
        JSONObject res = client.asr(audioBytes, "pcm", 16000, null);
        return res.toString();
    }



}
